home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / tex / meta27 / mfpandor.lzh / pandor.mf < prev    next >
Text File  |  1990-11-16  |  33KB  |  771 lines

  1. %*****************************************************************************
  2. %        Copyright (c) 1989 by N. N. Billawala
  3. %*****************************************************************************
  4.  
  5.  
  6. % pandor.mf  a base file which contains the macros used for creating Pandora
  7.  
  8.  
  9. %*****MAJOR CHARACTER PART MACROS**************************************
  10.  
  11.  
  12. boolean its_a_leftserif;                % in horizontal serif macro 
  13.  
  14. vardef full_serif_points@#(expr A,B,Bl,Br,leftlength,rightlength)=
  15.   min_limit(join_radius)(.5serif_thickness);
  16.   (z1-B)=whatever*(A@#-B@#);            % makes center ref line
  17.   (z1l-Bl)=whatever*(A@#-B@#);          % makes parallel ref line on left
  18.   (z1r-Br)=whatever*(A@#-B@#);          % makes parallel ref line on right
  19.  
  20.   y2=y2l=y2r=ypart A;                   % base of serif 
  21.   y1=y1l=y1r=y3=y4=ypart A if ypart A>ypart B:-else:+fi serif_thickness;
  22.                                         % puts serif_thickness between A and B
  23.   x5=x2=.5[x1l,x1r];                    % puts entasis at mid-base and makes it
  24.   y5=entasis[y2l,y1l];                  %   a proportion of the serif_thickness
  25.  
  26.   if its_a_leftserif:x3=x2l=x1l-round(leftlength+serif_constant_amt); 
  27.    else:x4=x2r=x1r+round(rightlength+serif_constant_amt); fi
  28. enddef;                      
  29.  
  30. vardef leftserif@#(expr A,B,Bl,Br,alength)=its_a_leftserif:=true;  % left serif
  31.   save x,y,p; path p[]; 
  32.   full_serif_points@#(A,B,Bl,Br,alength,0);                
  33.   p0:=Bl{z1l-Bl} if ctrls:..controls(onstem[z1l,Bl])and(onbase[z1l,z3])..
  34.      else:...fi {z3-z1l}z3;                        % the bracket curve
  35.   if midbracket_pull<>0: 
  36.     z3'l=z1l; pos3'(alength+5pt,.5[angle(B-A),if ypart A>ypart B:-fi 180]);
  37.     z8'=p0 intersectionpoint (z3'l--z3'r);         % z3'l--z3'r bisects bracket
  38.     z8=(midbracket_pull-eps)[z8',z1l];fi           % bracket pulled in at z8
  39.   if ypart A>ypart B:reverse fi   
  40.   ((if midbracket_pull=0:p0 else:Bl{z1l-Bl}...z8...{z3-z1l}z3 fi 
  41.    if softpath:)softjoin(z3--z2l)softjoin(else:--fi z2l..z5{right}))
  42. enddef;
  43.  
  44. vardef rightserif@#(expr A,B,Bl,Br,alength)=its_a_leftserif:=false;% right serif
  45.   save x,y,p; path p[]; 
  46.   full_serif_points@#(A,B,Bl,Br,0,alength);
  47.   p4:=z4{z1r-z4} if ctrls:..controls(onbase[z1r,z4])and(onstem[z1r,Br])..
  48.      else:...fi {Br-z1r}Br;                        % the bracket curve
  49.   if midbracket_pull<>0:
  50.     z4'l=z1r; pos4'(alength+5pt,.5[angle(B-A),0]);
  51.     z9'=p4 intersectionpoint (z4'l--z4'r);         % z4'l--z4'r bisects bracket
  52.     z9=(midbracket_pull-eps)[z9',z1r];fi           % bracket pulled in at z9
  53.   if ypart A>ypart B:reverse fi
  54.    ((z5{right}..z2r if softpath:)softjoin(z2r--z4)softjoin(else:--fi
  55.     if midbracket_pull=0:p4 else:z4{z1r-z4}...z9...{Br-z1r}Br fi))
  56. enddef;
  57.                             
  58. vardef fullserif@#(expr A,B,Bl,Br,leftlength,rightlength)=         % full serif
  59.   save x,y,p; path p[];
  60.   p1=rightserif(A,B,Bl,Br,rightlength); p2=leftserif(A,B,Bl,Br,leftlength);
  61.   if ypart A>ypart B:(p1--p2)else:(p2--p1)fi
  62. enddef;
  63.  
  64.  
  65.  
  66. vardef terminalserif@#(expr A,B,Bl,Br,tip_length,base_angle)suffix$=
  67.  
  68.   save x,y,join_radius,aleft,atop,arc,ball,heel,midbracket_point,tip,p; 
  69.   boolean aleft,atop; pair arc,ball,heel,midbracket_point,tip; path p[];
  70.   aleft=(str@#="l"); atop=(ypart A>ypart B);
  71.  
  72.   heel- if aleft:Br else:Bl fi =whatever*(A-B);  
  73.   heel=A+(whatever,0)rotated(if not aleft:180+ fi base_angle);
  74.   ball- if aleft:Bl else:Br fi =whatever*(A-B); ball=whatever[heel,A]; 
  75.  
  76.   z0=A if atop:-else:+fi(0,terminal_thickness) rotated base_angle;
  77.                     % z0 added for cases of small terminal_thickness and length
  78.   z2=whatever[ball,if aleft:Bl else:Br fi]; (z0-z2)=whatever*(ball-A);
  79.                     % terminal_thickness and stem intersection when no bracket
  80.   z1=z2+(tip_length+serif_constant_amt,0)rotated angle(ball-A);
  81.                     % z1 is an inner tip point
  82.   tip=whatever[heel,ball]; z1-tip=whatever*(z0-A);
  83.                     % places tip on base by an amount past the stem
  84.   z3=heel if str$="soft":+(terminal_softness+1,0)rotated angle(tip-heel)fi;
  85.   arc=.5[z3,tip]+(terminal_entasis*terminal_thickness,0)rotated angle(B-A);
  86.  
  87.   if aleft:z5=Bl; z6=Br; else:z5=Br; z6=Bl;fi
  88.   p1=z5{ball-z5} if ctrls:
  89.        ..controls(onstem[z2,z5])and(onbase[z2,(-eps)[z1,tip]])..
  90.          else:...fi {z1-z2}(-eps)[z1,tip]--z1;
  91.   join_radius:=min(terminal_softness,abs(heel-z3),.5abs(heel-z6));
  92.   p2=(arc{heel-tip}...z3{heel-tip}...{heel-tip}heel 
  93.      if str$="soft":)softjoin(heel fi --z6);
  94.   min_limit(join_radius)(.5terminal_thickness);
  95.  
  96.   if midbracket_pull<>0:
  97.     bisecting_angle:=if aleft and(sign(angle(B-A))<>sign(angle(ball-A))):
  98.                     180+fi .5[angle(B-A),angle(ball-A)];
  99.                     % this angle bisects the inner angle/area of the bracket
  100.     z4=z2+(tip_length+5pt+serif_constant_amt,0)rotated bisecting_angle;
  101.                     % sets point z4 for a reference path along bisecting angle
  102.     midbracket_point=(z2--z4)intersectionpoint p1;
  103.                     % midbracket_point intersects the reference path along the 
  104.                     % bisecting angle and the reference path of the bracket
  105.     z9=(midbracket_pull-eps)[midbracket_point,z2];   
  106.                     % the final path goes through z9, which gives the amount of
  107.                     % "pull" toward the point where the stem meets the terminal
  108.     fi              % base with no bracketing
  109.  
  110.   if atop=aleft:reverse fi
  111.    ((if midbracket_pull=0:p1
  112.       else:z5{ball-z5}...z9...{z1-z2}(-eps)[z1,z2]--z1 fi
  113.     if softpath:)softjoin(z1--tip)softjoin(else:--fi
  114.     tip..arc{heel-tip}--p2))
  115. enddef;
  116.     
  117.  
  118. vardef arm@#                                 % uses @#strings of tl,tr,bl,br
  119.   (expr heel,inner_ref,outer_ref,tip_length,tipthickness,base_angle)suffix$=
  120.  
  121.   save x,y,innertip,outertip,toward,control_point,tip_direction,midbase,section;
  122.   pair innertip,outertip,toward,control_point,tip_direction,midbase; 
  123.   path section[];             % separate parts of path for different join_radii
  124.   save_bool(atop)=((str@#="tr")or(str@#="tl"));
  125.   save_bool(curvedarm)=(atop and (ypart outer_ref>ypart heel))  or 
  126.                        ((not atop) and (ypart outer_ref<ypart heel)); 
  127.  
  128.   toward=(xpart heel-xpart outer_ref,0);       % direction going toward the heel
  129.   tip_direction=dir(base_angle if atop:+180 fi-oblique); 
  130.   z0=whatever[heel,heel+eps*tip_direction]; y0=ypart inner_ref;
  131.   outertip=if not curvedarm:z0+(tip_length,0) 
  132.     else:heel+(max(tip_length,abs(z0-heel)),0) fi  rotated angle tip_direction;
  133.   midbase=.5[outertip,heel];
  134.   innertip=outertip+tipthickness*           
  135.            dir(base_angle+if((str@#="tl")or(str@#="bl")):- else:+fi 90-oblique);
  136.   control_point-innertip=whatever*(heel-outertip);
  137.   control_point=whatever[inner_ref,z0];
  138.   save_num(join_radius)=
  139.     min(.5abs(outertip-heel),abs(heel-outer_ref),arm_softness);
  140.   section1=(midbase--heel)softjoin(heel...outer_ref{-toward});
  141.   section2=
  142.    (inner_ref{toward}
  143.       if curvedarm:...
  144.           if abs(innertip-control_point)>abs(inner_ref-control_point):
  145.           if atop:{downward} else:{upward} fi fi
  146.         else:..controls(onstem[control_point,inner_ref])and
  147.                        (onbase[control_point,innertip])..{outertip-heel} fi 
  148.     innertip if softpath:)softjoin(innertip--outertip)softjoin( else:--fi
  149.     outertip--midbase);
  150.  
  151.   if ((str@#="tl")or(str@#="br")):reverse fi  (section2--section1)
  152. enddef;
  153.  
  154. vardef bulb@#                                                      % like arm
  155.  (expr heel,inner_ref,outer_ref,tip_length,tipthickness,base_angle)suffix$=
  156.  save x,y,athickness,alength,bulb_taper_angle; z0=heel;
  157.  if bulbs: save_bool(softpath)=true; fi 
  158.  if bulb_taper:athickness=1; bulb_thickness:=athickness;
  159.     bulb_taper_angle=base_angle 
  160.       if((str@#="tr")or(str@#="bl")):-else:+fi taper_angle;
  161.     alength=if (c_and_s.lc<>0)or(c_and_s.uc<>0):max else:min fi
  162.             (abs(ypart outer_ref-ypart inner_ref),tip_length);
  163.   else:athickness=tipthickness;alength=tip_length;bulb_taper_angle=base_angle;fi
  164.  arm@#(z0,inner_ref,outer_ref,alength,athickness,bulb_taper_angle)$
  165. enddef;
  166.  
  167.  
  168. vardef shortarm@#(expr AA,BB,CC,D,E,F)suffix$=  % short form inspired by DEK
  169.   save x,y,GG,HH,II,JJ,KK,LL,M; pair GG,